﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Utils;

namespace COFE.Core.Filter
{
    [EntryFilter("filename")]
    public class FileNameEntryFilter : EntryFilterBase
    {
        public FileNameEntryFilter(string name, string id = "filename")
            : base(name, id)
        {
            SupportedMatchType = MatchType.MatchThisEntry;
        }

        public override MatchType matches(IInternalFileSystemInfoExA entry,
            params IOptionFilter[] options)
        {
            string name = Value;
            
            bool match = StringUtils.MatchFileMask(
                name.IndexOf('.') != -1 ?
                entry.Name : 
                COFEPath.RemoveExtension(entry.Name)                 
                , name);

            return match ? MatchType.MatchThisEntry : MatchType.None;
        }
        
    }
}
